package com.geek.framework.study.config.microprofile.converter;


import java.util.Objects;

public class ConvertEntry {

    private final Class<?> sourceType;

    private final Class<?> targetType;


    public static ConvertEntry stringSourceEntry(Class<?> targetType) {
        return new ConvertEntry(String.class, targetType);
    }


    public ConvertEntry(Class<?> sourceType, Class<?> targetType) {
        this.sourceType = sourceType;
        this.targetType = targetType;
    }


    public Class<?> getSourceType() {
        return sourceType;
    }

    public Class<?> getTargetType() {
        return targetType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ConvertEntry that = (ConvertEntry) o;
        return Objects.equals(sourceType, that.sourceType) &&
                Objects.equals(targetType, that.targetType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sourceType, targetType);
    }

}

